using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace CMSApplication.Models.Mapping
{
    public class ContentMap : EntityTypeConfiguration<Content>
    {
        public ContentMap()
        {
            // Primary Key
            this.HasKey(t => t.content_id);

            // Properties
            this.Property(t => t.content_id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.content_markdown)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("Content");
            this.Property(t => t.content_id).HasColumnName("content_id");
            this.Property(t => t.content_markdown).HasColumnName("content_markdown");
            this.Property(t => t.styles_id).HasColumnName("styles_id");
            this.Property(t => t.ElementID).HasColumnName("ElementID");

            // Relationships
            this.HasRequired(t => t.HtmlElement)
                .WithMany(t => t.Contents)
                .HasForeignKey(d => d.ElementID);

        }
    }
}
